package com.teamall.web.sjtj.controller;

import com.teamall.core.common.JModelAndView;
import com.teamall.framework.util.DateUtils;
import com.teamall.framework.util.JsonUtil;
import com.teamall.framework.util.Utils;
import com.teamall.web.sjtj.service.IJzbsService;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.Map;

/**
 * ${DESCRIPTION}
 *
 * @author
 * @create 2017-09-08 0:08
 **/
@RequestMapping("/sjtj/jzsb")
@Controller
public class JzsbController {
    @Autowired
    private IJzbsService jzbsService;
    @RequestMapping("/pkfb")
    public ModelAndView pkfbMain(String date){
        if(Utils.isEmpty(date)){
            date = DateUtils.date2String(new Date(),"yyyy");
        }
        ModelAndView modelAndView = new JModelAndView("/sjtj/jzsb_pkfb");
        Map resultMap = jzbsService.getPkfbMain(date);
        String chatDataJson = JsonUtil.toJson(resultMap.get("chatData"));
        modelAndView.addObject("resultMap",resultMap);
        modelAndView.addObject("chatDataJson",chatDataJson);
        modelAndView.addObject("date",date);
        return modelAndView;
    }
    @RequestMapping("/zpyy")
    public ModelAndView zpyyMain(String date){
        ModelAndView modelAndView = new JModelAndView("/sjtj/jzsb_zpyy");
        if(Utils.isEmpty(date)){
            date = DateUtils.date2String(new Date(),"yyyy");
        }
        Map resultMap = jzbsService.getZpyyMain(date);
        String chatDataJson = JsonUtil.toJson(resultMap.get("chatData"));
        modelAndView.addObject("resultMap",resultMap);
        modelAndView.addObject("chatDataJson",chatDataJson);
        modelAndView.addObject("date",date);
        return modelAndView;
    }
    @RequestMapping("/pksr")
    public ModelAndView pkslMain(String date){
        ModelAndView modelAndView = new JModelAndView("/sjtj/jzsb_pksr");
        if(Utils.isEmpty(date)){
            date = DateUtils.date2String(new Date(),"yyyy");
        }
        Map resultMap = jzbsService.getPksrMain(date);
        modelAndView.addObject("resultMap",resultMap);
        modelAndView.addObject("date",date);
        return modelAndView;
    }
}
